﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.DesignServer
{
    public static class CZEnvironment
    {
        private static Version _version;
        /// <summary>
        /// 获得主程序的版本号
        /// </summary>
        public static Version Version
        {
            get
            {
                if (_version == null)
                {
                    _version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;
                }
                return _version;
            }
        }

        /// <summary>
        /// 版本信息-.-.-
        /// </summary>
        public static string Version3
        {
            get
            {
                return Version.ToString(3);
            }
        }

        /// <summary>
        /// 版本信息-.-.-.-
        /// </summary>
        public static string Version4
        {
            get
            {
                return Version.ToString(4);
            }
        }

        public static string GetLogDirectory()
        {
            return string.Format("{0}\\Coolzon\\Logs\\v{1}\\Server\\",
                Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                Version4);
        }

        /// <summary>
        /// 获取host配置信息的文件路径
        /// </summary>
        /// <returns></returns>
        public static string GetHostConfigFilePath()
        {
            return string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "Config\\host.xml");
        }

        /// <summary>
        /// 获取日志配置文件的路径
        /// </summary>
        /// <returns></returns>
        public static string GetLoggerConfigFilePath()
        {
            return string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "Config\\log.xml");
        }
    }
}
